package 树;


import 排序算法.测试.TimeUtil;
import 集合.FileOperation;

import java.util.ArrayList;

public class TestTrie {
    public static void main(String[] args) {
        ArrayList<String> words = new ArrayList<>();
        FileOperation.readFile("动态数组\\a-tale-of-two-cities.txt",words);
        testTrie(words);
        testAVLTreeMap(words);
    }

    private static void testAVLTreeMap(ArrayList<String> words) {
        TimeUtil tu = new TimeUtil();
        tu.start();
        AVLTreeMap<String,Integer> map = new AVLTreeMap<>();
        for (String word : words) {
            if (!map.contains(word)) {
                map.put(word,1);
            } else {
                map.set(word,map.get(word) + 1);
            }
        }
        System.out.println(map.size());
        System.out.println(map.get("she"));
        tu.stop();
        tu.show();
    }

    private static void testTrie(ArrayList<String> words) {
        TimeUtil tu = new TimeUtil();
        tu.start();
        Trie trie = new Trie();
        for (String word : words) {
            trie.add(word);
        }
        System.out.println(trie.size());
        System.out.println(trie.totalSize());
        System.out.println(trie.count("she"));
        tu.stop();
        tu.show();
    }
}
